def rerank(articles):
    """
    对召回的文档进行重排序
    """
    print(f"🔍 rerank开始处理，输入文档数量: {len(articles) if articles else 0}")
    
    # 按分数排序，取前5个最相关的文档
    sorted_articles = sorted(articles, key=lambda x: x.score, reverse=True)
    result = sorted_articles[:5]
    
    print(f"✅ rerank完成，返回前5个文档:")
    for i, article in enumerate(result):
        print(f"   {i+1}. {article.name} (分数: {article.score})")
    
    return result 